import React from 'react';
import reactDOM from 'react-dom';
import {Route, HashRouter, BrowserRouter, Switch} from 'react-router-dom';

import Controller from "./home/Controller";
import TopicDetail from "./topic/detail/TopicDetail";

class App extends React.Component {

    constructor(props) {
        super(props);
        this.previousLocation = this.props.location
    }

    componentWillUpdate(nextProps) {
        const {location} = this.props
        console.log(nextProps);
        if (nextProps.history.action !== 'POP' && (!location.state)) {
            this.previousLocation = this.props.location;
        }
    }

    render() {
        return <div>
            <Switch location={this.props.location}>
                <Route exact path="/" component={Controller}></Route>
                <Route path="/topic/:id" component={TopicDetail}/>
            </Switch>
        </div>
    }
}

const rt = <BrowserRouter>
    <Route component={App}/>
</BrowserRouter>;

reactDOM.render(rt, document.getElementById("root"));

// import BE from './BasicEx';
// import MG from './MG';
//
// reactDOM.render(MG(), document.getElementById("root"));

